<?php 
	$categories = $this->category_model->getAll(array('parent_id' => 0,'language_id' => $this->config->item('lang_obj')->id))->result();
	$metals = explode(',',$this->config->item('metals_for_filter'));
	$shapes = explode(';',$this->config->item('shape_filter'));
	$sizes = explode(';',$this->config->item('carat_filter'));
	$qualities = explode(';',$this->config->item('quality_filter'));
	$settings = explode(';',$this->config->item('setting_filter'));
	$colours = explode(';',$this->config->item('color_filter'));
?>
<div id="left-menu" class="left">
	<div class="left-menu-item">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand open" onClick="closeFilter(this)"><span><?php echo lang('shop_by_price_text')?></span></div>
			<div class="ul">
				<div class="li">
					<span style="display:inline-block;width:30px;"><?php echo lang('min')?>:</span> 
					<input type="text" class="price-btn" name="min_price" id="min_price" value="<?php echo (isset($search['price_more_orig']) ? $search['price_more_orig'] : '')?>">
				</div>
				<div class="li">
					<span style="display:inline-block;width:30px;"><?php echo lang('max')?>:</span> 
					<input type="text" class="price-btn" name="max_price" id="max_price" value="<?php echo (isset($search['price_less_orig']) ? $search['price_less_orig'] : '')?>">
				</div>
				<div class="li" style="text-align:center;padding-right:15px;">
					<?php echo $sel_currency?>
				</div>
				<div style="text-align: center;">
					<div id="search_price_btn" style="margin-top:10px;"><?php echo lang('search');?></div>
				</div>
			</div>
		</div>
	</div>
	<?php if (count($categories)){?>
	<div class="left-menu-item">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand open" onClick="closeFilter(this)"><span><?php echo lang('shop_by_category_text')?></span></div>
			<ul>
				<?php 
				$count = 0;
				$class = '';
				foreach($categories as $category){
					if ($count > 4 AND $class == ''){
						$class = "additional-category";
					}
					
					$count++;
					echo "<li class='" . $class . " " . ((isset($search['category']) AND $search['category'] == $category->id) ?"selected" : '') . "'><a href='" . get_category_url($category->name, $category->id) . "'>" . $category->name . "</a></li>";
					
				 } 
				 if ($count > 4){
				 	echo "<li><a href='javascript:void(0)' onClick='showMore(\"category\",this)'> + " . lang('show_more') . "</a></li>";
				 }
				 ?>
			</ul>
		</div>
	</div>
	
	
	<?php if(isset($styles) AND !empty($styles)){?>
		<div class="left-menu-item">
			<div class="head-item-wrap rounded-corners light-brown-border">
				<div class="head-item-main hand open"><span><?php echo lang('shop_by_style')?></span></div>
				<ul>
					<?php 
					$count = 0;
					$class = '';
					foreach($styles as $style){
						if ($count > 4 AND $class == ''){
							$class = 'additional-style';
						}
					
						$total = $controller->getNumRows($category_id, get_filter_url('style',$style->name, 1));
						if ($total) {
							$count++;						
							echo "<li class='" . $class . " " . ((isset($search['style']) AND $search['style'] == $style->name) ?"selected" : '') . "'><a href='" . get_filter_url('style',$style->name) . "'>" . $style->name . "</a></li>";
						}
					 } 
					 if ($count > 4){
					 	echo "<li><a href='javascript:void(0)' onClick='showMore(\"style\",this)'> + " . lang('show_more') . "</a></li>";
					 }
					 ?>
				</ul>
			</div>
		</div>
	<?php }
	}
	if (count($metals)){
	?>
	<div class="left-menu-item">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand open" onClick="closeFilter(this)"><span><?php echo lang('shop_by_metal_text')?></span></div>
			<ul>
				<?php 
				$count = 0;
				$class = '';
				foreach($metals as $metal){
					if ($count > 4 AND $class == ''){
						$class = 'class="additional-metal"';
					}
					$category_id = (isset($category_id))? $category_id: 0;
					$total = $controller->getNumRows($category_id, get_filter_url('metal', lang($metal), 1));
					if ($total) {
						$count++;
						echo "<li class='" . $class . " " . ((isset($search['metal']) AND $search['metal'] == lang($metal)) ?"selected" : '') . "'><a href='" . get_filter_url('metal',lang($metal)) . "'>" . lang($metal) . "</a></li>";
					}
				 } 
				 if ($count > 4){
				 	echo "<li><a href='javascript:void(0)' onClick='showMore(\"metal\",this)'> + " . lang('show_more') . "</a></li>";
				 }
				 ?>
			</ul>
		</div>
	</div>
	<?php }?>
	<div class="left-menu-item">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand open" onClick="closeFilter(this)"><span><?php echo lang('shop_by_gem_text')?></span></div>
			<ul>
				<?php
				$total = $controller->getNumRows($category_id, get_filter_url('gem', lang('search_diamond'), 1));
				if ($total) {
				?>
				<li class='<?php echo ((isset($search['gem']) AND $search['gem'] == lang('search_diamond')) ?"selected" : '')?>'><a href="<?php echo get_filter_url('gem',lang('search_diamond'));?>" ><?php echo lang('search_diamond')?></a></li>
				<?php
				}
				$total = $controller->getNumRows($category_id, get_filter_url('gem', lang('search_sapphire'), 1));
				if ($total) {		 
				?>
				<li class='<?php echo ((isset($search['gem']) AND $search['gem'] == lang('search_sapphire')) ?"selected" : '')?>'><a href="<?php echo get_filter_url('gem',lang('search_sapphire'));?>" ><?php echo lang('search_sapphire')?></a></li>
				<?php 
				}
				$total = $controller->getNumRows($category_id, get_filter_url('gem', lang('search_ruby'), 1));
				if ($total) {
				?>
				<li class='<?php echo ((isset($search['gem']) AND $search['gem'] == lang('search_ruby')) ?"selected" : '')?>'><a href="<?php echo get_filter_url('gem',lang('search_ruby'));?>" ><?php echo lang('search_ruby')?></a></li>
				<?php
				}
				$total = $controller->getNumRows($category_id, get_filter_url('gem', lang('search_emerald'), 1));
				if ($total) { 
				?>
				<li class='<?php echo ((isset($search['gem']) AND $search['gem'] == lang('search_emerald')) ?"selected" : '')?>'><a href="<?php echo get_filter_url('gem',lang('search_emerald'));?>" ><?php echo lang('search_emerald')?></a></li>
				<?php

				}
				?>
			</ul>
		</div>
	</div>
	
	<div class="left-menu-item">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand open" onClick="showFilters(this)"><span><?php echo lang('show_all_filter')?></span></div>
		</div>
	</div>
	
	<div class="left-menu-item supplimentar_filter">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand closed" onClick="closeFilter(this)"><span><?php echo lang('shop_by_stone_shape')?></span></div>
			<?php if (isset($shapes) AND !empty($shapes)){?>
			<ul style="display:none">
			<?php foreach ($shapes as $key=>$shape){
				if (strlen($shape)){
					$total = $controller->getNumRows($category_id, get_filter_url('shape',lang($shape), 1));
					if ($total) {
						echo "<li class='" . ((isset($search['shape']) AND $search['shape'] == lang($shape)) ?"selected" : '') . "'><a href='" . get_filter_url('shape',lang($shape)) . "'>" . lang($shape) . "</a></li>";
					}
				}
			}					
			?>
			</ul>
			<?php }?>
		</div>
	</div>
	
	<div class="left-menu-item supplimentar_filter">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand closed" onClick="closeFilter(this)"><span><?php echo lang('shop_by_diamond_size')?></span></div>
			<?php if (isset($sizes) AND !empty($sizes)){?>
			<ul style="display:none">
			<?php foreach ($sizes as $key=>$size){
				if (strlen($size)){
					$size_parts = explode('-', $size);
					if ($size_parts[0] == 0){
						$size_name = " < " . $size_parts[1] . ' CT';
					} else {
						$size_name = $size_parts[0] . ' CT - ' . $size_parts[1] . ' CT';
					}
					$total = $controller->getNumRows($category_id, get_filter_url('size',$size, 1));
					if ($total) {
						echo "<li class='" . ((isset($search['size']) AND $search['size'] == lang($size)) ?"selected" : '') . "'><a href='" . get_filter_url('size',$size) . "'>" . $size_name . "</a></li>";
					}
				}
			}					
			?>
			</ul>
			<?php }?>
		</div>
	</div>
	
	<div class="left-menu-item supplimentar_filter">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand closed" onClick="closeFilter(this)"><span><?php echo lang('shop_by_diamond_quality')?></span></div>
			<?php if (isset($qualities) AND !empty($qualities)){?>
			<ul style="display:none">
			<?php foreach ($qualities as $key=>$quality){
				if (strlen($quality)){
					$total = $controller->getNumRows($category_id, get_filter_url('quality',$quality, 1));
					if ($total) {					
						echo "<li class='" . ((isset($search['quality']) AND $search['quality'] == lang($quality)) ?"selected" : '') . "'><a href='" . get_filter_url('quality',$quality) . "'>" . strtoupper($quality) . "</a></li>";
					}
				}
			}					
			?>
			</ul>
			<?php }?>
		</div>
	</div>
	
	<div class="left-menu-item supplimentar_filter">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand closed" onClick="closeFilter(this)"><span><?php echo lang('shop_by_settings')?></span></div>
			<?php if (isset($settings) AND !empty($settings)){?>
			<ul style="display:none">
			<?php foreach ($settings as $key=>$setting){
				if (strlen($setting) AND lang($setting) != '['.$setting.']'){
					$total = $controller->getNumRows($category_id, get_filter_url('setting',lang($setting), 1));
					if ($total) {						
						echo "<li class='" . ((isset($search['setting']) AND $search['setting'] == lang($setting)) ?"selected" : '') . "'><a href='" . get_filter_url('setting',lang($setting)) . "'>" . lang($setting) . "</a></li>";
					}
				}
			}					
			?>
			</ul>
			<?php }?>
		</div>
	</div>
	<div class="left-menu-item supplimentar_filter">
		<div class="head-item-wrap rounded-corners light-brown-border">
			<div class="head-item-main hand closed" onClick="closeFilter(this)"><span><?php echo lang('shop_by_colour')?></span></div>
			<?php if (isset($colours) AND !empty($colours)){?>
			<ul style="display:none">
			<?php foreach ($colours as $key=>$colour){
				if (strlen($colour) AND lang($colour . '_color') != '['.$colour.'_color]'){
					$total = $controller->getNumRows($category_id, get_filter_url('color',$colour, 1));
					if ($total) {					
						echo "<li class='" . ((isset($search['color']) AND $search['color'] == lang($color)) ?"selected" : '') . "'><a class=\"upper\" href='" . get_filter_url('color',$colour) . "'>".$colour .  "</a></li>"; /*lang($colour . '_color') .*/
					}
				}
			}					
			?>
			</ul>
			<?php }?>
		</div>
	</div>
	
</div>